package com.atguigu.springanalysis.listener;

import com.atguigu.springanalysis.event.BlackListEvent;
import com.atguigu.springanalysis.event.EntityCreatedEvent;
import com.atguigu.springanalysis.model.Person;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

public class BlackListNotifier2 {
    private String notificationAddress;

    public void setNotificationAddress(String notificationAddres) {
        this.notificationAddress = notificationAddress;
    }

    @EventListener(condition = "#event.test=='foo'")
    @Async
    @Order(42)
    public void handleEvent(BlackListEvent event) {
        System.out.println(event.getTimestamp());
    }

    @EventListener
    public void onPersonCreated(EntityCreatedEvent<Person> event) { }

    @EventListener({ContextStartedEvent.class, ContextRefreshedEvent.class})
    public void handleEvent2() {

    }
}
